# Standard Makfile

CC = cc
ASM = nasm
LD = ld

CFLAGS = -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./includes -I./includes/libc
ASMFLAGS = -f elf
LDFLAGS = -T ../link.ld

OBJS = boot.o main.o gdt.o idt.o isrs.o irqs.o sysclock.o drivers.o
BUILD_OBJS = boot.o main.o gdt.o idt.o isrs.o irqs.o sysclock.o

PROG = kernel

# Compile the kernel
all: $(PROG)

clean:
	rm -rf $(OBJS);
	cd libc; rm -rf *.o; cd ../
	cd drivers; rm -rf *.o; cd ../

$(PROG): $(OBJS)
	$(LD) $(LDFLAGS) -o $(PROG) $(OBJS)

boot.o: boot.asm
	$(ASM) $(ASMFLAGS) boot.asm -o boot.o

main.o: main.c
	$(CC) $(CFLAGS) -c -o main.o main.c

gdt.o: gdt.c
	$(CC) $(CFLAGS) -c -o gdt.o gdt.c

idt.o: idt.c
	$(CC) $(CFLAGS) -c -o idt.o idt.c

isrs.o: isrs.c
	$(CC) $(CFLAGS) -c -o isrs.o isrs.c

irqs.o: irqs.c
	$(CC) $(CFLAGS) -c -o irqs.o irqs.c

sysclock.o: sysclock.c
	$(CC) $(CFLAGS) -c -o sysclock.o sysclock.c

##
## OTHER
##

libc:
	cd libc; make; cd ../

drivers:
	cd drivers; make; cd ../

modules:
	cd modules; make; cd ../
